<?php 

namespace Admin\Controller;
use Think\Controller;
class UserController extends BaseController{

public function userList(){

			$usersModel=M('users');
			$users=$usersModel->order('id')->select();
			$this->users=$users;
			$this->display();		   
}
public function deluser($id){
		//$id = $_GET['id'];
	$usersModel=M('users');
	$res=$userModel->where("id=$id")->find();
	echo $res->getLastSql();
       $photoPath=realpath('./Public/Admin/photo/'.$res['photo']);
        if($res['photo']!=='default.jpg')
        {
        unlink($photoPath);}

	if(false!==$usersModel->where("id=$id")->delete())
		$this->success('删除成功！');
	else
		{ $this->error('删除失败');
	}
	   
}
public function edituser(){
	$id = $_GET['id'];
	$usersModel=M('users');
	$data['password']='123';
	$res=$usersModel->where("id=$id")->save($data);
	echo $usersModel->getLastSql();
		//$data['aliasname']='1234123123231156';
	if(false!==$res)
		$this->success('密码重置成功！');
	else
		{ $this->error('密码重置失败');
	}
}

public function zt(){
	$id = $_GET['id'];
	$usersModel=M('users');
	$data['state']='1';
	$res=$usersModel->where("id=$id")->save($data);
	if(false!==$res)
		$this->success('成功！');
	else
		{ $this->error('失败');
	}
}
public function hf(){
	$id = $_GET['id'];
	$usersModel=M('users');
	$data['state']='0';
	$res=$usersModel->where("id=$id")->save($data);
	if(false!==$res)
		$this->success('成功！');
	else
		{ $this->error('失败');
	}
}


}


 ?>